package k1_exercise;

import java.util.Arrays;
import java.util.Scanner;

public class Array_exercise_fifth {
    /**
     * 定义一个数组，用来存储 1 1 2 3 5 8 13……这样的菲波那切数列，存储该数列的前20个数
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入斐波那契数列的个数：");
        int count = scanner.nextInt();

        //创建数组
        int[] fibonacci = new int[count];
        //固定数组中的前两个值
        fibonacci[0] = 1;
        fibonacci[1] = 1;

        for (int i = 2; i < count; i++) {
            fibonacci[i] = fibonacci[i-1]+fibonacci[i-2];
        }

        System.out.println(Arrays.toString(fibonacci));

    }
}
